package com.abe.libquick.utils;

import android.text.TextUtils;

import java.util.Calendar;
import java.util.TimeZone;

public class DateTimeHelper {
    //默认时间选择器开始结束时间
    public static final Long defaultStartTime = 970380000000L;////2000-10-01 14:00:00
    public static final Long defaultEndTime = 32527288800000L;////3000-10-01 14:00:00

    /**
     * 获取当天（按当前传入的时区）00:00:00/24:00:00所对应时刻的long型值
     *
     * @param now      传入选中日期时间戳
     * @param isStart  0点/24点
     * @param timeZone 时区
     */
    public static long getTimeOfDay(long now, boolean isStart, String timeZone) {
        String tz = TextUtils.isEmpty(timeZone) ? "GMT+8" : timeZone;
        TimeZone curTimeZone = TimeZone.getTimeZone(tz);
        Calendar calendar = Calendar.getInstance(curTimeZone);
        calendar.setTimeInMillis(now);
        calendar.set(Calendar.HOUR_OF_DAY, isStart ? 0 : 24);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar.getTimeInMillis();
    }
}